import crypto from 'crypto'
import fs from 'fs'
import path from 'path';

const { publicKey, privateKey } = crypto.generateKeyPairSync('rsa', {
    modulusLength: 4096,
    publicKeyEncoding: {
        type: 'spki',
        format: 'pem',
    },
    privateKeyEncoding: {
        type: 'pkcs8',
        format: 'pem',
        cipher: 'aes-256-cbc',
        passphrase: 'viya.top',
    }
})

fs.writeFileSync(path.resolve('src/0030_加解密/sra/public.pem'), publicKey, 'utf8')
fs.writeFileSync(path.resolve('src/0030_加解密/sra/private.pem'), privateKey, 'utf8')

console.log('生成的公钥');
console.log(publicKey);
console.log('生成的私钥');
console.log(privateKey);





